package br.com.winesys.geta.databinding.component.editor;

import java.math.BigDecimal;
import java.text.NumberFormat;
import java.text.ParseException;

public class BigDecimalEditor extends NumberEditor {

	public BigDecimalEditor() {
		super();
		setFormat("#,##0.00");
	}

	public BigDecimalEditor(String format) {
		super(format);
	}

	public BigDecimalEditor(NumberFormat format) {
		super(format);
	}

	@Override
	public Object getValue() {
		if (this.getText().trim().isEmpty()) {
			return null;
		}
		try {
			return new BigDecimal(this.getFormatter().stringToValue(this.getText()).toString());
		} catch (ParseException ex) {
			return null;
		}
	}
}
